﻿@{
    Layout = null;
    MICZ.CodeBuilder.ViewModels.WorkContent WorkContent = ViewBag.WorkContent;
}
<script src="@WorkContent.ThemePath/js/jquery-3.4.1.min.js"></script>
<link href="@WorkContent.ThemePath/layui/css/layui.css" rel="stylesheet" />
<script src="@WorkContent.ThemePath/layui/layui.js"></script>
<script src="@WorkContent.ThemePath/bais.js"></script>

<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="password" name="UID" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">辅助文字</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="Password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">请输入密码</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" name="PWD" required lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">确认密码</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选择框</label>
        <div class="layui-input-block">
            <select name="Role" lay-verify="required">
                <option value="普通用户">普通用户</option>
            </select>
        </div>
    </div>
    <div class="form-input">
        <input type="text" name="vcode" id="vcode" required lay-verify="required" placeholder="验证码" autocomplete="off"
               class="layui-input" onblur="if(this.value==''){this.value='验证码'}" onclick="if(this.value=='验证码'){this.value='';}" value="验证码">
        <img id="checkloing" src="/API/VerifyCode/Img" width="70" height="40" onclick="reloadcode('/API/VerifyCode/Img')" title="看不清，换一张" style="" />
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    //刷新验证码 js脚本代码
    function reloadcode(srcStr) {
        document.getElementById("checkloing").src = srcStr + "?rand=" + Math.random();
    }
    //Demo
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var layer = layui.layer;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            //layer.msg(JSON.stringify(data.field));
            if ($("input[name='Password']").val() != $("input[name='PWD']").val()) {
                layer.msg("两次输入的密码不一致，请重新输入");
                return false;
            }
            $.ajax({
                //请求方式
                type: 'POST',
                //发送请求的地址
                url: '/AdminAPI/Login/AddUser',
                //服务器返回的数据类型
                dataType: 'json',
                //发送到服务器的数据，对象必须为key/value的格式，jquery会自动转换为字符串格式
                data: $('form').serialize(),
                success: function (data) {
                    //请求成功函数内容
                    layer.msg(data.Msg);
                },
                error: function (data) {
                    //请求失败函数内容
                    layer.msg("数据请求错误!");//直接错误
                }
            });
            return false;
        });
    });
</script>